package com.vcredit.creditcat.web.app;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vcredit.creditcat.api.ICreditCardAppylyManager;
import com.vcredit.creditcat.model.Cust;
import com.vcredit.creditcat.model.CustRecommendCard;
import com.vcredit.creditcat.vo.CreditCardAppylyRecord;
import com.vcredit.creditcat.vo.CreditCardAppylyRecordVo;

/***
 * 申请信用卡相关接口
 * @author luquan
 *
 */
@RestController
@RequestMapping(value = "/creditCardApply")
public class CreditCardApplyController extends BaseCreditCatController {

	
	@Reference(version="1.0")
	private ICreditCardAppylyManager CreditCardAppylyManager;
	
	@RequestMapping(value = "/getApplyRecords")
	public CreditCardAppylyRecordVo getApplyRecords(HttpServletRequest request){
		Cust cust = super.getCust(request);
		CreditCardAppylyRecordVo recordVo = new CreditCardAppylyRecordVo();
		List<CreditCardAppylyRecord> records = new ArrayList<CreditCardAppylyRecord>();
	    List<CustRecommendCard> list = CreditCardAppylyManager.getApplyRecords(cust.getCustId());
	    for(CustRecommendCard card :list){
	    	CreditCardAppylyRecord record = new CreditCardAppylyRecord();
	    	record.setName(card.getCardName());
	    	record.setDesc(card.getRecommendCard().getCardTitle());
	    	record.setIconUrl(card.getRecommendCard().getCardIcon());
	    	record.setApplyTime(card.getCreateTime().getTime());
	    	records.add(record);
	    }
	    recordVo.setApplyRecords(records);
		return recordVo;
		
	}
}
